Aql queries

Basic Model Queries

DescriptionWorkbench SelectionSyntax
Current Element Model Elementaql:self
Container of current elementA model element aql:self.eContainer()
Type of an elementA model elementaql:self.eClass()
Total number of elements in a modelA model elementaql:self.ancestors()->last().eAllContents()->size()
Total number of sub-elementsA model elementaql:self.eAllContents()->size()


Diagram Queries

DescriptionWorkbench SelectionSyntax
Semantic element associated to a graphical elementA diagram / A diagram elementaql:self.target
aird file (non fragmented model)A diagramancestor.eClass().name = 'DAnalysis')->asSet())
All aird files (fragmented model)A diagramaql: self.getAllDAnalysis()
All diagramsA diagramaql: self.getAllDAnalysis().ownedViews.ownedRepresentationDescriptors
Number of diagramsA diagramaql: self.getAllDAnalysis().ownedViews.ownedRepresentationDescriptors->size()
All diagrams from kind "Logical Data Flow"A diagramx.description.name.startsWith('Logical Data Flow Blank'))'''
All diagrams except kind "Scenario"A diagramx.description.name.endsWith('Scenario') = false)'''
List of different viewpointsA diagramaql: self.getAllDAnalysis().ownedViews.viewpoint->asSet()
Number of graphical elements in all diagramsA diagramaql: self.getAllDAnalysis().ownedViews.ownedRepresentationDescriptors.representation.diagramElements->size()
Number of graphical elements in all diagrams (including technical elements like style, color…)A diagramaql: self.getAllDAnalysis().ownedViews.ownedRepresentationDescriptors.representation.eAllContents()->size()

Searching Strings

DescriptionWorkbench SelectionSyntax
All element containing the "TODO" string in their 'Name' propertyA model elementeAllContent.name.matches('.*TODO.*'))'''
All element containing the "TODO" string in their 'Summary' propertyA model elementeAllContent.summary.matches('.*TODO.*'))'''
All element containing the "TODO" string in their 'Description' propertyA model elementeAllContent.description.matches('.*TODO.*'))'''
All diagrams containing a note containing the "TODO" stringA diagramx.eInverse('element')->filter(notation::Diagram).eAllContents(notation::Node)->select(x | x.type = 'Note' and x.description.contains('TODO')))'''
Number of diagrams containing a note containing the "TODO" stringA diagramx.eInverse('element')->filter(notation::Diagram).eAllContents(notation::Node)->select(x | x.type = 'Note' and x.description.contains('TODO')))->size()'''

Requirements

DescriptionWorkbench SelectionSyntax
Query to retrieve the list of non-allocated requirementsRequirement Packagex.getRelatedCapellaElements()->isEmpty())'''

Model Navigation Examples

DescriptionWorkbench SelectionSyntax
List of functions allocated to a componentAny Componentaql:self.allocatedFunctions
List of sub logical componentsAny Logical Componentaql:self.subLogicalComponents
List of all functions

- having more than 3 ports - allocated to one given component - Which name starts with "Store"

Any ComponentallocatedFunction.name.startsWith('Store') and allocatedFunction.eAllContents()->filter(fa::FunctionPort)->size() > 3)

Metrics

DescriptionWorkbench SelectionSyntax
Number of YYYY::XXXX owned by the selected element, where XXXX is the type of a model element (aql:self.eClass() ) and YYYY the last term of its packageA model elementaql:self.eAllContents(YYYY::XXXX)->size()
Number of Operational ActivitiesOperationalAnalysisaql:self.eAllContents(oa::OperationalActivity)->size()
Number of Operational InteractionsOperationalAnalysisaql:self.eAllContents(fa::FunctionalExchange)->size()
Number of Exchange Items in OAOperationalAnalysisaql:self.eAllContents(modellingcore::AbstractExchangeItem)->size()
Number of Types (Classes, Datatypes) in OAOperationalAnalysisaql:self.eAllContents(datatype::DataType)->size()
Number of Classes in OAOperationalAnalysis

aql:self.eAllContents(information::Class)->size()

Number of States or Modes in OAOperationalAnalysisaql:(self.eAllContents()->filter(capellacommon::State) - self.eAllContents()->filter(capellacommon::Mode))->size()
Number of Operational EntitiesOperationalAnalysisaql:(self.eAllContents(oa::Entity) - self.eAllContents(oa::OperationalActor))->size()
Number of Operational ActorsOperationalAnalysisaql:self.eAllContents(oa::OperationalActor)->size()
Number of Operational RolesOperationalAnalysisaql:self.eAllContents(oa::Role)->size()
Number of Communication MeansOperationalAnalysisaql:self.eAllContents(oa::CommunicationMean)->size()
Number of System FunctionsSystemAnalysisaql:self.eAllContents(ctx::SystemFunction)->size()
Number of Functional Exchanges in SASystemAnalysisaql:self.eAllContents(fa::FunctionalExchange)->size()
Number of Function Ports in SASystemAnalysisaql:self.eAllContents()->filter(fa::FunctionPort)->size()
Number of System ActorsSystemAnalysisaql:self.eAllContents(ctx::Actor)->size()
Number of Functional Chains in SASystemAnalysisaql:self.eAllContents(fa::FunctionalChain)->size()
Number of Scenarios in SASystemAnalysisaql:self.eAllContents(interaction::Scenario)->size()
Number of Behaviour Components in PAPhysicalArchitectureeAllContent.nature = pa::PhysicalComponentNature::BEHAVIOR)->size()
Number of Implementation PC (nodes) in PAPhysicalArchitectureeAllContent.nature = pa::PhysicalComponentNature::NODE)->size()
Number of Physical LinksPhysicalArchitectureaql:self.eAllContents(cs::PhysicalLink)->size()
Number of Physical PortsPhysicalArchitectureaql:self.eAllContents(cs::PhysicalPort)->size()

Advanced Queries

With Aql, you can navigate in elements following references and attributes: aql:self.outgoing on a SystemFunction will retrieve outgoing functional exchanges:



There is many way to retrieve which references to use for an element. These references ca be used in a request like the above outgoing reference. For instance, you can retrieve references with Aql using the following request: aql:self.eClass().eAllReferences (or self.eClass().eAllAttributes to retrieve attributes)



One easiest way to retrieve references or attributes is to open the Properties View and go the Expert tab then choose relevant references/attributes for your query



You just have to write the reference name in a camelCaseFormat to use it with Aql (e.g. Available In States => availableInStates) or in some case with the corresponding getter function